<?php
declare(strict_types=1);

namespace App\Common\Extend\Guard\Drives;

use Hyperf\Contract\SessionInterface;

class SessionDrives implements DrivesInterface
{
    public function set(string $key, mixed $data, $ttl = 0): void
    {
        container(SessionInterface::class)->set($key, $data);
    }

    public function get(string $key): mixed
    {
        return container(SessionInterface::class)->get($key);
    }

    public function delete(string|array $keys): void
    {
        if (is_string($keys)) {
            $keys = [$keys];
        }
        foreach ($keys as $key) {
            container(SessionInterface::class)->remove($key);
        }
    }
}